package com.feib.soeasy.model;

import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * @title (#)FormatDefinition.java<br>
 * @description 帳單匯入格式(收款類別)/ 繳費者匯入格式 定義<br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/11/10 create by Jimmy Liu<br>
 */
@Entity
@Table(name = "FORMAT_DEFINITION")
public class FormatDefinition extends AuditEntity {

    private static final long serialVersionUID = 186914808736741026L;
    
    /**
     * PK in Table
     */
    private Long formatDefinitionPk;
    
    /**
     * 所屬帳單業者
     */
    private Group group;
    
    /**
     * 檔案格式名稱
     */
    private String formatName;
    
    /**
     * 刪除
     */
    private Boolean deleted;
    
    /**
     * 自動產生繳款單使用
     */
    private Boolean batchUsed;
    
    /**
     * 轉入類別
     * 1 : 繳費單資料
     * 2 : 繳款人資料
     */
    private Integer formatType;
    
    /**
     * 客製化檢核 Class Name
     */
    private String customValidateClass;
    
    /**
     * Jasper jrxml 檔案路徑(完整路徑檔名)
     */
    private String jrxmlPath;
    
    /**
     * 客製化繳費單PDF Class Name
     */
    private String customPdfClass;
    
    /**
     * 欄位定義
     */
    private List<ColumnDefinition> columnDefinitions;
    
    private Set<CommissionCodeTable> commissionCodeTables;

    
    /**
     * @return the formatDefinitionPk
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="FORMAT_DEF_PK", nullable=false)
    public Long getFormatDefinitionPk() {
        return formatDefinitionPk;
    }

    
    /**
     * @param formatDefinitionPk the formatDefinitionPk to set
     */
    public void setFormatDefinitionPk(Long formatDefinitionPk) {
        this.formatDefinitionPk = formatDefinitionPk;
    }

    
    /**
     * @return the group
     */
    @ManyToOne
    @JoinColumn(name="GROUP_PK", nullable=false)
    public Group getGroup() {
        return group;
    }

    
    /**
     * @param group the group to set
     */
    public void setGroup(Group group) {
        this.group = group;
    }

    
    /**
     * @return the formatName
     */
    @Column(name="FORMAT_NAME", nullable=false, length=255)
    public String getFormatName() {
        return formatName;
    }

    
    /**
     * @param formatName the formatName to set
     */
    public void setFormatName(String formatName) {
        this.formatName = formatName;
    }


    /**
     * @return the deleted
     */
    @Column(name="IS_DELETED", nullable=false)
    public Boolean getDeleted() {
        return deleted;
    }

    
    /**
     * @param deleted the deleted to set
     */
    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    
    
    /**
     * @return the customValidateClass
     */
    @Column(name="CUSTOM_VALIDATE_CLASS", length=100)
    public String getCustomValidateClass() {
        return customValidateClass;
    }


    
    /**
     * @param customValidateClass the customValidateClass to set
     */
    public void setCustomValidateClass(String customValidateClass) {
        this.customValidateClass = customValidateClass;
    }


    
    /**
     * @return the jrxmlPath
     */
    @Column(name="JRXML_PATH", length=255)
    public String getJrxmlPath() {
        return jrxmlPath;
    }


    
    /**
     * @param jrxmlPath the jrxmlPath to set
     */
    public void setJrxmlPath(String jrxmlPath) {
        this.jrxmlPath = jrxmlPath;
    }


    
    /**
     * @return the customPdfClass
     */
    @Column(name="CUSTOM_PDF_CLASS", length=100)
    public String getCustomPdfClass() {
        return customPdfClass;
    }


    
    /**
     * @param customPdfClass the customPdfClass to set
     */
    public void setCustomPdfClass(String customPdfClass) {
        this.customPdfClass = customPdfClass;
    }


    /**
     * @return the columnDefinitions
     */
    @OneToMany(cascade = CascadeType.ALL, mappedBy="formatDefinition", orphanRemoval =true)
    public List<ColumnDefinition> getColumnDefinitions() {
        return columnDefinitions;
    }

    
    /**
     * @param columnDefinitions the columnDefinitions to set
     */
    public void setColumnDefinitions(List<ColumnDefinition> columnDefinitions) {
        this.columnDefinitions = columnDefinitions;
    }


    
    /**
     * @return the commissionCodeTables
     */
    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
    @JoinTable(name = "FORMAT_DEF_COMMISSION", joinColumns = @JoinColumn(name = "FORMAT_DEF_PK"), inverseJoinColumns = @JoinColumn(name = "COMMISSION_CODE_PK"))
    public Set<CommissionCodeTable> getCommissionCodeTables() {
        return commissionCodeTables;
    }


    
    /**
     * @param commissionCodeTables the commissionCodeTables to set
     */
    public void setCommissionCodeTables(Set<CommissionCodeTable> commissionCodeTables) {
        this.commissionCodeTables = commissionCodeTables;
    }


    
    /**
     * @return the formatType
     */
    @Column(name="FORMAT_TYPE", nullable = false)
    public Integer getFormatType() {
        return formatType;
    }


    
    /**
     * @param formatType the formatType to set
     */
    public void setFormatType(Integer formatType) {
        this.formatType = formatType;
    }


    
    /**
     * @return the batchUsed
     */
    @Column(name="BATCH_USED")
    public Boolean getBatchUsed() {
        return batchUsed;
    }


    
    /**
     * @param batchUsed the batchUsed to set
     */
    public void setBatchUsed(Boolean batchUsed) {
        this.batchUsed = batchUsed;
    }
}
